using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DomainLayer.Data.Entities;

namespace Infrastructure.Data.Mapping
{
	public class UploadOrderRecordMap : EntityTypeConfiguration<UploadOrderRecord>
	{
		public UploadOrderRecordMap()
		{
			// Primary Key
			this.HasKey(t => t.ID);

			// Properties
			this.Property(t => t.UserAccount)
				.HasMaxLength(20);
				
			this.Property(t => t.Remark)
				.HasMaxLength(200);
				
			this.Property(t => t.FileName)
				.HasMaxLength(100);
				
			// Table & Column Mappings
			this.ToTable("UploadOrderRecord");
			this.Property(t => t.ID).HasColumnName("ID");
			this.Property(t => t.BatchNo).HasColumnName("BatchNo");
			this.Property(t => t.MerchantID).HasColumnName("MerchantID");
			this.Property(t => t.CreateTime).HasColumnName("CreateTime");
			this.Property(t => t.Quantity).HasColumnName("Quantity");
			this.Property(t => t.UserAccount).HasColumnName("UserAccount");
			this.Property(t => t.Remark).HasColumnName("Remark");
			this.Property(t => t.IsDeleted).HasColumnName("IsDeleted");
			this.Property(t => t.IsSucceed).HasColumnName("IsSucceed");
			this.Property(t => t.FileName).HasColumnName("FileName");

			// Relationships
			this.HasRequired(t => t.MerchantBaseInfo)
				.WithMany(t => t.UploadOrderRecords)
				.HasForeignKey(d => d.MerchantID);
				
		}
	}
}

